namespace jsWrite {
    let myBind = function(this:any,context:any,...rest:Array<any>):any{
        if(typeof this != "function"){
            console.error("type error!");
        }
        context = context??globalThis;
        context.fn = this as Function;
        let result = context.fn(...rest);
        context.fn = null;
        delete context.fn;
        return result;
    }

    let obj = {name:'ls'};
    function demo(this:any,age:number){
        console.log(this);
        console.log(this.name);
        this.age = age
    }
    demo.myBind = myBind;
    demo.myBind(obj,18)
    console.log(obj);
}